package com.polaris.live.adapter.chatPrice

import android.view.View
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterChatLevelBinding
import com.polaris.live.resp.back_resp.AppCallPriceBaseVo

/**
 * 聊天价格等级
 *
 * @author Created by 长空 on 2023/11/08/004 09:31
 */
class ChatLevelAdapter :
    BaseBindingAdapter<AdapterChatLevelBinding, AppCallPriceBaseVo>() {

    private var modifyLevel: Int = -1
    private var isDetail: Boolean = false

    override fun convert(holder: VBViewHolder<AdapterChatLevelBinding>, item: AppCallPriceBaseVo) {
        holder.vb.apply {
            tvLevel.setLevel(item.level)
            if (modifyLevel != -1 && item.level >= modifyLevel) {
                tvModified.visibility = View.VISIBLE
            } else {
                tvModified.visibility = View.GONE
            }
            if (isDetail) {
                tvDiamond.text = item.beans.toString()
                ivDiamond.visibility = View.GONE
                tvMin.visibility = View.GONE
            } else {
                tvDiamond.text = item.price.toString()
                ivDiamond.visibility = View.VISIBLE
                tvMin.visibility = View.VISIBLE
            }
        }
    }

    fun setModifyLevel(modifyLevel: Int) {
        this.modifyLevel = modifyLevel
    }

    fun setIsDetail(isDetail: Boolean) {
        this.isDetail = isDetail
    }

}